import type { IFormItem } from '@/components/NFormBuilder/types'
import type { CreateFormItemsOptions } from '@/types/fcform'
import { ScConstants } from '@/components/NFormBuilder/unit/ScConstants'
export const createFormItems = (options: CreateFormItemsOptions): IFormItem[] => {
  const sc = new ScConstants(24)
  const { formData, optionsState } = options
  return [
    sc.image('头像', 'avatar'),
    sc.input('昵称', 'nickname'),
    sc.input('用户名', 'username'),
    sc.input('姓名', 'name'),
    sc.input('手机号', 'phone'),
    sc.tree('部门', 'deptId', {
      options: optionsState.allTree,
      labelField: 'name',
      valueField: 'id',
      childrenField: 'children',
    }),
    sc.select('角色', 'role', {
      options: optionsState.routeList,
      labelField: 'roleName',
      valueField: 'roleId',
      multiple: true,
    }),
    sc.select('岗位', 'post', {
      options: optionsState.postList,
      labelField: 'postName',
      valueField: 'postId',
      multiple: true,
    }),
    {
      ...sc.input('密码', 'password', {
        type: 'password',
      }),
      hidden: () => !!formData.value.userId,
    },
    sc.switch('启用', 'lockFlag', {
      checkedValue: '1',
      uncheckedValue: '0',
    }),
  ]
}
